//
//  Homepage.swift
//  MyCookbook
//
//  Created by liaokylin on 2024/10/14.
//

import SwiftUI

struct Homepage: View {
    @State private var currentSelect: Int = 2

    var tabs :[TabItemValue] = [
        TabItemValue(id: 1, text: "关注"),
        TabItemValue(id: 2, text: "推荐"),
        TabItemValue(id: 3, text: "减脂"),
        TabItemValue(id: 4, text: "商店"),
        TabItemValue(id: 5, text: "分类"),
    ]
    
    var body: some View {
            VStack{
                    Tabs(currentSelect: $currentSelect, tabsItems:tabs)
                    TabView(selection:$currentSelect){
                        ForEach(tabs){ tab in
                            switch currentSelect {
                            case 1:
                                Attention().tag(tab.id)
                            case 2:
                                Recommend().tag(tab.id)
                            case 3:
                                LoseFat().tag(tab.id)
                            case 4:
                                Store().tag(tab.id)
                            case 5:
                                Classification().tag(tab.id)
                            default:
                                EmptyView()
                            }
                        }
                    }.tabViewStyle(.page(indexDisplayMode: .never))
                
            }.frame(maxWidth: /*@START_MENU_TOKEN@*/.infinity/*@END_MENU_TOKEN@*/,maxHeight: .infinity)
    }
}

#Preview {
    Homepage()
}
